/**
 * 访客模型 
 * 
*/
module.exports = (sequelize, Sequelize) => {
    return sequelize.define("visitor", {
        id: {
            type: Sequelize.UUID,
            notNull: true,
            primaryKey: true,
            defaultValue: Sequelize.UUIDV4,
            get() { // UUID的自动递增
                return () => {
                    return this.getDataValue('id');
                };
            }
        },
        userName: {
            type: Sequelize.STRING,
            comment: '用户名',
            field:'user_name'
        },
        browser: {
            type: Sequelize.STRING,
            notEmpty: true,
            notNull: true,
            comment: '浏览器',
        },
        os: {
            type: Sequelize.STRING,
            notEmpty: true,
            notNull: true,
            comment: '操作系统',
        },
        type: {
            type: Sequelize.INTEGER,
            notEmpty: true,
            notNull: true,
            comment: '项目类型',
        },
        count: {
            type: Sequelize.INTEGER,
            notEmpty: true,
            notNull: true,
            comment: '访问次数',
            defaultValue: 1
        },
        ipaddr: {
            type: Sequelize.STRING,
            notEmpty: true,
            notNull: true,
            comment: 'IP',
        },
        loginLocation: {
            type: Sequelize.STRING,
            notEmpty: true,
            notNull: true,
            comment: '地址',
            field:'login_location'
        },
    })
}